package com.lcz.googleplay.config;

import com.yolanda.nohttp.rest.Response;
import com.yolanda.nohttp.rest.SimpleResponseListener;

/**
 * Created by hp on 2016/10/27.
 */

public class HomeProtocol extends BaseProtocol {
    @Override
    public String load(final int index) {
        //读取本地缓存
        String json = loadLocal(index);
        if (json != null) {
            return json;
        } else {
            //重新请求服务器
            loadServer(getKey(), index);
            /*SimpleResponseListener<String> listener = new SimpleResponseListener<String>() {
                @Override
                public void onSucceed(int what, Response<String> response) {
                    super.onSucceed(what, response);
                    saveLocal(response.get(), index);
                }

                @Override
                public void onFailed(int what, Response<String> response) {
                    super.onFailed(what, response);
                }
            };
            AppConfig.loadServer(getKey(), index, listener);*/
        }
        return null;
    }

    @Override
    public String getKey() {
        return "home";

    }
}
